package cn.hackcloud.netty.basic.bio;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;

public class TimeClient {
	public static void main(String[] args) {
		Socket serverSocket = null;
		try {
			serverSocket = new Socket("127.0.0.1", 8888);
			InputStream inputStream = serverSocket.getInputStream();
			BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
			OutputStream outputStream = serverSocket.getOutputStream();
			PrintWriter printWriter = new PrintWriter(outputStream, true);
			printWriter.println("TIME");
			System.out.println(reader.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (serverSocket != null) {
				try {
					serverSocket.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
